package com.linwen.excise.leetcode;

import java.util.Arrays;

/**
 * @ClassName _242有效的字母异位词
 * @Description TODO
 * @Author zero
 * @DATE 2024/9/28 5:20 PM
 * @Version 1.0
 */
public class _242有效的字母异位词 {
    public static void main(String[] args) {
        _242有效的字母异位词 inst = new _242有效的字母异位词();
        String s = "anagram", t = "nagaram";
        System.out.println(inst.isAnagram(s,t));
    }
    public boolean isAnagram(String s, String t) {
        if (s.length() != t.length()) {
            return false;
        }
        char[] str1 = s.toCharArray();
        char[] str2 = t.toCharArray();
        Arrays.sort(str1);
        Arrays.sort(str2);
        return Arrays.equals(str1, str2);
    }
}
